<!-- 咨询 -->
<template>
	<view>
		<list-zixun :tabBars="tabBars" :tabIndex="tabIndex" @tabtap="tabtap"></list-zixun>
		<swiper class="swiper-box heighly" :style="{ height: highly + 'px' }" :current="tabIndex" @change="tabChange">
			<swiper-item v-for="(item, index) in tabBars" :key="index">
				<!-- 内容 -->
				<scroll-view scroll-y="true" class="list" @scrolltolower="reachBottom">
					<view class="u-m-20">
						<!-- 轮播图 -->
						<u-swiper :list="banner" height="180" width="100%" keyName="image" showTitle :autoplay="true" circular></u-swiper>
						<!-- 资料 -->
						<view class="u-m-t-20">
							<view class="u-flex u-flex-between u-flex-wrap">
								<view class="Reset" v-for="(it, id) in dataList" :key="id" @click="nextNav('/pages/zixun/xiangQing?id=' + it.id + (it.video_file ? '&type=video' : ''))">
									<view class="zixun-box u-rela">
										<!-- <u--image mode="scaleToFill" radius="3" width="100%" height="165" :src="it.image" :lazy-load="true"><u-loading slot="loading"></u-loading></u--image> -->
										<image mode="scaleToFill" class="zixun-box" :src="it.image || df"></image>
										<view class="u-abso R-eset" v-if="type && tabIndex === 0"><u-icon name="bofang" customPrefix="master" color="#fff" size="30"></u-icon></view>
									</view>
									<view class="u-p-25 u-font-30">{{ it.title }}</view>
								</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</swiper-item>
		</swiper>
		<u-loading-page loading-text="内当家APP" :loading="pageLoad"></u-loading-page>
	</view>
</template>

<script>
export default {
	data() {
		return {
			tabIndex: 0, // 选中的
			tabBars: [],
			banner: [],
			dataList: [],
			type: false
		};
	},
	async onLoad() {
		let about = await this.require('getcompanyconfig');
		if (about) {
			for (var i = 0; i < about.length; i++) {
				if (about[i].title === '视频展示') {
					this.type = about[i].value == 2;
				}
			}
		}
		let res = await this.require('getnewscategory');
		if (res) {
			let obj = res[0];
			res.splice(0, 1);
			if (this.type) {
				res.unshift(obj);
			}
			this.tabBars = res;
			this.path = 'getNews';
			this.params = {
				...this.params,
				pnum: this.pnum,
				category_id: this.tabBars[this.tabIndex].id
			};
			await this.getList();
		}
		let res1 = await this.require('bannerlist');
		if (res1) {
			this.banner = res1;
		}
		this.pageLoad = false;
	},
	onShow() {
		this.xinxiao();
	},
	methods: {
		async tabtap(index) {
			this.params.p = 1;
			this.params.category_id = this.tabBars[this.tabIndex].id;
			this.pageLoad = true;
			await this.getList();
			if (this.pageLoad) {
				setTimeout(() => {
					this.pageLoad = false;
					this.tabIndex = index;
				}, 1000);
			}
		},
		//滑动切换导航
		tabChange(e) {
			this.tabtap(e.detail.current);
		}
	}
};
</script>

<style lang="scss" scoped>
.Reset {
	width: 345rpx;
	background: #fff;
	margin-bottom: 20rpx;
	border-radius: 10rpx;
	overflow: hidden;
}

.v-h-z {
	width: 100%;
	height: auto;
	margin: auto;
}

// #ifdef H5 || MP-WEIXIN
.video {
	width: 330rpx;
	height: 310rpx;
	border-top-left-radius: 15rpx;
	border-top-right-radius: 15rpx;
}

// #endif
.R-eset {
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
}

.zixun-box {
	width: 345rpx !important;
	height: 275rpx !important;
	background-color: #f4f4f6;
}

.list {
	height: calc(100vh - (100rpx));
}
</style>
